1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.IconView; 26 27 private import gdk.ContentFormats; 28 private import gdk.PaintableIF; 29 private import glib.ConstructionException; 30 private import glib.ListG; 31 private import glib.MemorySlice; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import gtk.CellArea; 35 private import gtk.CellLayoutIF; 36 private import gtk.CellLayoutT; 37 private import gtk.CellRenderer; 38 private import gtk.ScrollableIF; 39 private import gtk.ScrollableT; 40 private import gtk.Tooltip; 41 private import gtk.TreeIter; 42 private import gtk.TreeModelIF; 43 private import gtk.TreePath; 44 private import gtk.Widget; 45 private import gtk.c.functions; 46 public import gtk.c.types; 47 private import std.algorithm; 48 49 50 /** 51 * `GtkIconView` is a widget which displays data in a grid of icons. 52 * 53 * `GtkIconView` provides an alternative view on a `GtkTreeModel`. 54 * It displays the model as a grid of icons with labels. Like 55 * [class@Gtk.TreeView], it allows to select one or multiple items 56 * (depending on the selection mode, see [method@Gtk.IconView.set_selection_mode]). 57 * In addition to selection with the arrow keys, `GtkIconView` supports 58 * rubberband selection, which is controlled by dragging the pointer. 59 * 60 * Note that if the tree model is backed by an actual tree store (as 61 * opposed to a flat list where the mapping to icons is obvious), 62 * `GtkIconView` will only display the first level of the tree and 63 * ignore the tree’s branches. 64 * 65 * # CSS nodes 66 * 67 * ``` 68 * iconview.view 69 * ╰── [rubberband] 70 * ``` 71 * 72 * `GtkIconView` has a single CSS node with name iconview and style class .view. 73 * For rubberband selection, a subnode with name rubberband is used. 74 */ 75 public class IconView : Widget, CellLayoutIF, ScrollableIF 76 { 77 /** the main Gtk struct */ 78 protected GtkIconView* gtkIconView; 79 80 /** Get the main Gtk struct */ 81 public GtkIconView* getIconViewStruct(bool transferOwnership = false) 82 { 83 if (transferOwnership) 84 ownedRef = false; 85 return gtkIconView; 86 } 87 88 /** the main Gtk struct as a void* */ 89 protected override void* getStruct() 90 { 91 return cast(void*)gtkIconView; 92 } 93 94 /** 95 * Sets our main struct and passes it to the parent class. 96 */ 97 public this (GtkIconView* gtkIconView, bool ownedRef = false) 98 { 99 this.gtkIconView = gtkIconView; 100 super(cast(GtkWidget*)gtkIconView, ownedRef); 101 } 102 103 // add the CellLayout capabilities 104 mixin CellLayoutT!(GtkIconView); 105 106 // add the Scrollable capabilities 107 mixin ScrollableT!(GtkIconView); 108 109 110 /** */ 111 public static GType getType() 112 { 113 return gtk_icon_view_get_type(); 114 } 115 116 /** 117 * Creates a new `GtkIconView` widget 118 * 119 * Returns: A newly created `GtkIconView` widget 120 * 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this() 124 { 125 auto __p = gtk_icon_view_new(); 126 127 if(__p is null) 128 { 129 throw new ConstructionException("null returned by new"); 130 } 131 132 this(cast(GtkIconView*) __p); 133 } 134 135 /** 136 * Creates a new `GtkIconView` widget using the 137 * specified @area to layout cells inside the icons. 138 * 139 * Params: 140 * area = the `GtkCellArea` to use to layout cells 141 * 142 * Returns: A newly created `GtkIconView` widget 143 * 144 * Throws: ConstructionException GTK+ fails to create the object. 145 */ 146 public this(CellArea area) 147 { 148 auto __p = gtk_icon_view_new_with_area((area is null) ? null : area.getCellAreaStruct()); 149 150 if(__p is null) 151 { 152 throw new ConstructionException("null returned by new_with_area"); 153 } 154 155 this(cast(GtkIconView*) __p); 156 } 157 158 /** 159 * Creates a new `GtkIconView` widget with the model @model. 160 * 161 * Params: 162 * model = The model. 163 * 164 * Returns: A newly created `GtkIconView` widget. 165 * 166 * Throws: ConstructionException GTK+ fails to create the object. 167 */ 168 public this(TreeModelIF model) 169 { 170 auto __p = gtk_icon_view_new_with_model((model is null) ? null : model.getTreeModelStruct()); 171 172 if(__p is null) 173 { 174 throw new ConstructionException("null returned by new_with_model"); 175 } 176 177 this(cast(GtkIconView*) __p); 178 } 179 180 /** 181 * Creates a `GdkPaintable` representation of the item at @path. 182 * This image is used for a drag icon. 183 * 184 * Params: 185 * path = a `GtkTreePath` in @icon_view 186 * 187 * Returns: a newly-allocated `GdkPaintable` of the drag icon. 188 */ 189 public PaintableIF createDragIcon(TreePath path) 190 { 191 auto __p = gtk_icon_view_create_drag_icon(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 192 193 if(__p is null) 194 { 195 return null; 196 } 197 198 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p, true); 199 } 200 201 /** 202 * Turns @icon_view into a drop destination for automatic DND. Calling this 203 * method sets `GtkIconView`:reorderable to %FALSE. 204 * 205 * Params: 206 * formats = the formats that the drag will support 207 * actions = the bitmask of possible actions for a drag to this 208 * widget 209 */ 210 public void enableModelDragDest(ContentFormats formats, GdkDragAction actions) 211 { 212 gtk_icon_view_enable_model_drag_dest(gtkIconView, (formats is null) ? null : formats.getContentFormatsStruct(), actions); 213 } 214 215 /** 216 * Turns @icon_view into a drag source for automatic DND. Calling this 217 * method sets `GtkIconView`:reorderable to %FALSE. 218 * 219 * Params: 220 * startButtonMask = Mask of allowed buttons to start drag 221 * formats = the formats that the drag will support 222 * actions = the bitmask of possible actions for a drag from this 223 * widget 224 */ 225 public void enableModelDragSource(GdkModifierType startButtonMask, ContentFormats formats, GdkDragAction actions) 226 { 227 gtk_icon_view_enable_model_drag_source(gtkIconView, startButtonMask, (formats is null) ? null : formats.getContentFormatsStruct(), actions); 228 } 229 230 /** 231 * Gets the setting set by gtk_icon_view_set_activate_on_single_click(). 232 * 233 * Returns: %TRUE if item-activated will be emitted on a single click 234 */ 235 public bool getActivateOnSingleClick() 236 { 237 return gtk_icon_view_get_activate_on_single_click(gtkIconView) != 0; 238 } 239 240 /** 241 * Fills the bounding rectangle in widget coordinates for the cell specified by 242 * @path and @cell. If @cell is %NULL the main cell area is used. 243 * 244 * This function is only valid if @icon_view is realized. 245 * 246 * Params: 247 * path = a `GtkTreePath` 248 * cell = a `GtkCellRenderer` 249 * rect = rectangle to fill with cell rect 250 * 251 * Returns: %FALSE if there is no such item, %TRUE otherwise 252 */ 253 public bool getCellRect(TreePath path, CellRenderer cell, out GdkRectangle rect) 254 { 255 return gtk_icon_view_get_cell_rect(gtkIconView, (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct(), &rect) != 0; 256 } 257 258 /** 259 * Returns the value of the ::column-spacing property. 260 * 261 * Returns: the space between columns 262 */ 263 public int getColumnSpacing() 264 { 265 return gtk_icon_view_get_column_spacing(gtkIconView); 266 } 267 268 /** 269 * Returns the value of the ::columns property. 270 * 271 * Returns: the number of columns, or -1 272 */ 273 public int getColumns() 274 { 275 return gtk_icon_view_get_columns(gtkIconView); 276 } 277 278 /** 279 * Fills in @path and @cell with the current cursor path and cell. 280 * If the cursor isn’t currently set, then *@path will be %NULL. 281 * If no cell currently has focus, then *@cell will be %NULL. 282 * 283 * The returned `GtkTreePath` must be freed with gtk_tree_path_free(). 284 * 285 * Params: 286 * path = Return location for the current 287 * cursor path 288 * cell = Return location the current 289 * focus cell 290 * 291 * Returns: %TRUE if the cursor is set. 292 */ 293 public bool getCursor(out TreePath path, out CellRenderer cell) 294 { 295 GtkTreePath* outpath = null; 296 GtkCellRenderer* outcell = null; 297 298 auto __p = gtk_icon_view_get_cursor(gtkIconView, &outpath, &outcell) != 0; 299 300 path = ObjectG.getDObject!(TreePath)(outpath); 301 cell = ObjectG.getDObject!(CellRenderer)(outcell); 302 303 return __p; 304 } 305 306 /** 307 * Determines the destination item for a given position. 308 * 309 * Params: 310 * dragX = the position to determine the destination item for 311 * dragY = the position to determine the destination item for 312 * path = Return location for the path of the item 313 * pos = Return location for the drop position 314 * 315 * Returns: whether there is an item at the given position. 316 */ 317 public bool getDestItemAtPos(int dragX, int dragY, out TreePath path, out GtkIconViewDropPosition pos) 318 { 319 GtkTreePath* outpath = null; 320 321 auto __p = gtk_icon_view_get_dest_item_at_pos(gtkIconView, dragX, dragY, &outpath, &pos) != 0; 322 323 path = ObjectG.getDObject!(TreePath)(outpath); 324 325 return __p; 326 } 327 328 /** 329 * Gets information about the item that is highlighted for feedback. 330 * 331 * Params: 332 * path = Return location for the path of 333 * the highlighted item 334 * pos = Return location for the drop position 335 */ 336 public void getDragDestItem(out TreePath path, out GtkIconViewDropPosition pos) 337 { 338 GtkTreePath* outpath = null; 339 340 gtk_icon_view_get_drag_dest_item(gtkIconView, &outpath, &pos); 341 342 path = ObjectG.getDObject!(TreePath)(outpath); 343 } 344 345 /** 346 * Gets the path and cell for the icon at the given position. 347 * 348 * Params: 349 * x = The x position to be identified 350 * y = The y position to be identified 351 * path = Return location for the path 352 * cell = Return location for the renderer 353 * responsible for the cell at (@x, @y) 354 * 355 * Returns: %TRUE if an item exists at the specified position 356 */ 357 public bool getItemAtPos(int x, int y, out TreePath path, out CellRenderer cell) 358 { 359 GtkTreePath* outpath = null; 360 GtkCellRenderer* outcell = null; 361 362 auto __p = gtk_icon_view_get_item_at_pos(gtkIconView, x, y, &outpath, &outcell) != 0; 363 364 path = ObjectG.getDObject!(TreePath)(outpath); 365 cell = ObjectG.getDObject!(CellRenderer)(outcell); 366 367 return __p; 368 } 369 370 /** 371 * Gets the column in which the item @path is currently 372 * displayed. Column numbers start at 0. 373 * 374 * Params: 375 * path = the `GtkTreePath` of the item 376 * 377 * Returns: The column in which the item is displayed 378 */ 379 public int getItemColumn(TreePath path) 380 { 381 return gtk_icon_view_get_item_column(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 382 } 383 384 /** 385 * Returns the value of the ::item-orientation property which determines 386 * whether the labels are drawn beside the icons instead of below. 387 * 388 * Returns: the relative position of texts and icons 389 */ 390 public GtkOrientation getItemOrientation() 391 { 392 return gtk_icon_view_get_item_orientation(gtkIconView); 393 } 394 395 /** 396 * Returns the value of the ::item-padding property. 397 * 398 * Returns: the padding around items 399 */ 400 public int getItemPadding() 401 { 402 return gtk_icon_view_get_item_padding(gtkIconView); 403 } 404 405 /** 406 * Gets the row in which the item @path is currently 407 * displayed. Row numbers start at 0. 408 * 409 * Params: 410 * path = the `GtkTreePath` of the item 411 * 412 * Returns: The row in which the item is displayed 413 */ 414 public int getItemRow(TreePath path) 415 { 416 return gtk_icon_view_get_item_row(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 417 } 418 419 /** 420 * Returns the value of the ::item-width property. 421 * 422 * Returns: the width of a single item, or -1 423 */ 424 public int getItemWidth() 425 { 426 return gtk_icon_view_get_item_width(gtkIconView); 427 } 428 429 /** 430 * Returns the value of the ::margin property. 431 * 432 * Returns: the space at the borders 433 */ 434 public int getMargin() 435 { 436 return gtk_icon_view_get_margin(gtkIconView); 437 } 438 439 /** 440 * Returns the column with markup text for @icon_view. 441 * 442 * Returns: the markup column, or -1 if it’s unset. 443 */ 444 public int getMarkupColumn() 445 { 446 return gtk_icon_view_get_markup_column(gtkIconView); 447 } 448 449 /** 450 * Returns the model the `GtkIconView` is based on. Returns %NULL if the 451 * model is unset. 452 * 453 * Returns: The currently used `GtkTreeModel` 454 */ 455 public TreeModelIF getModel() 456 { 457 auto __p = gtk_icon_view_get_model(gtkIconView); 458 459 if(__p is null) 460 { 461 return null; 462 } 463 464 return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) __p); 465 } 466 467 /** 468 * Gets the path for the icon at the given position. 469 * 470 * Params: 471 * x = The x position to be identified 472 * y = The y position to be identified 473 * 474 * Returns: The `GtkTreePath` corresponding 475 * to the icon or %NULL if no icon exists at that position. 476 */ 477 public TreePath getPathAtPos(int x, int y) 478 { 479 auto __p = gtk_icon_view_get_path_at_pos(gtkIconView, x, y); 480 481 if(__p is null) 482 { 483 return null; 484 } 485 486 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) __p, true); 487 } 488 489 /** 490 * Returns the column with pixbufs for @icon_view. 491 * 492 * Returns: the pixbuf column, or -1 if it’s unset. 493 */ 494 public int getPixbufColumn() 495 { 496 return gtk_icon_view_get_pixbuf_column(gtkIconView); 497 } 498 499 /** 500 * Retrieves whether the user can reorder the list via drag-and-drop. 501 * See gtk_icon_view_set_reorderable(). 502 * 503 * Returns: %TRUE if the list can be reordered. 504 */ 505 public bool getReorderable() 506 { 507 return gtk_icon_view_get_reorderable(gtkIconView) != 0; 508 } 509 510 /** 511 * Returns the value of the ::row-spacing property. 512 * 513 * Returns: the space between rows 514 */ 515 public int getRowSpacing() 516 { 517 return gtk_icon_view_get_row_spacing(gtkIconView); 518 } 519 520 /** 521 * Creates a list of paths of all selected items. Additionally, if you are 522 * planning on modifying the model after calling this function, you may 523 * want to convert the returned list into a list of `GtkTreeRowReferences`. 524 * To do this, you can use gtk_tree_row_reference_new(). 525 * 526 * To free the return value, use `g_list_free_full`: 527 * |[<!-- language="C" --> 528 * GtkWidget *icon_view = gtk_icon_view_new (); 529 * // Use icon_view 530 * 531 * GList *list = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (icon_view)); 532 * 533 * // use list 534 * 535 * g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); 536 * ]| 537 * 538 * Returns: A `GList` containing a `GtkTreePath` for each selected row. 539 */ 540 public ListG getSelectedItems() 541 { 542 auto __p = gtk_icon_view_get_selected_items(gtkIconView); 543 544 if(__p is null) 545 { 546 return null; 547 } 548 549 return new ListG(cast(GList*) __p, true); 550 } 551 552 /** 553 * Gets the selection mode of the @icon_view. 554 * 555 * Returns: the current selection mode 556 */ 557 public GtkSelectionMode getSelectionMode() 558 { 559 return gtk_icon_view_get_selection_mode(gtkIconView); 560 } 561 562 /** 563 * Returns the value of the ::spacing property. 564 * 565 * Returns: the space between cells 566 */ 567 public int getSpacing() 568 { 569 return gtk_icon_view_get_spacing(gtkIconView); 570 } 571 572 /** 573 * Returns the column with text for @icon_view. 574 * 575 * Returns: the text column, or -1 if it’s unset. 576 */ 577 public int getTextColumn() 578 { 579 return gtk_icon_view_get_text_column(gtkIconView); 580 } 581 582 /** 583 * Returns the column of @icon_view’s model which is being used for 584 * displaying tooltips on @icon_view’s rows. 585 * 586 * Returns: the index of the tooltip column that is currently being 587 * used, or -1 if this is disabled. 588 */ 589 public int getTooltipColumn() 590 { 591 return gtk_icon_view_get_tooltip_column(gtkIconView); 592 } 593 594 /** 595 * This function is supposed to be used in a `GtkWidget::query-tooltip` 596 * signal handler for `GtkIconView`. The @x, @y and @keyboard_tip values 597 * which are received in the signal handler, should be passed to this 598 * function without modification. 599 * 600 * The return value indicates whether there is an icon view item at the given 601 * coordinates (%TRUE) or not (%FALSE) for mouse tooltips. For keyboard 602 * tooltips the item returned will be the cursor item. When %TRUE, then any of 603 * @model, @path and @iter which have been provided will be set to point to 604 * that row and the corresponding model. 605 * 606 * Params: 607 * x = the x coordinate (relative to widget coordinates) 608 * y = the y coordinate (relative to widget coordinates) 609 * keyboardTip = whether this is a keyboard tooltip or not 610 * model = a pointer to receive a `GtkTreeModel` 611 * path = a pointer to receive a `GtkTreePath` 612 * iter = a pointer to receive a `GtkTreeIter` 613 * 614 * Returns: whether or not the given tooltip context points to an item 615 */ 616 public bool getTooltipContext(int x, int y, bool keyboardTip, out TreeModelIF model, out TreePath path, out TreeIter iter) 617 { 618 GtkTreeModel* outmodel = null; 619 GtkTreePath* outpath = null; 620 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 621 622 auto __p = gtk_icon_view_get_tooltip_context(gtkIconView, x, y, keyboardTip, &outmodel, &outpath, outiter) != 0; 623 624 model = ObjectG.getDObject!(TreeModelIF)(outmodel); 625 path = ObjectG.getDObject!(TreePath)(outpath); 626 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 627 628 return __p; 629 } 630 631 /** 632 * Sets @start_path and @end_path to be the first and last visible path. 633 * Note that there may be invisible paths in between. 634 * 635 * Both paths should be freed with gtk_tree_path_free() after use. 636 * 637 * Params: 638 * startPath = Return location for start of region 639 * endPath = Return location for end of region 640 * 641 * Returns: %TRUE, if valid paths were placed in @start_path and @end_path 642 */ 643 public bool getVisibleRange(out TreePath startPath, out TreePath endPath) 644 { 645 GtkTreePath* outstartPath = null; 646 GtkTreePath* outendPath = null; 647 648 auto __p = gtk_icon_view_get_visible_range(gtkIconView, &outstartPath, &outendPath) != 0; 649 650 startPath = ObjectG.getDObject!(TreePath)(outstartPath); 651 endPath = ObjectG.getDObject!(TreePath)(outendPath); 652 653 return __p; 654 } 655 656 /** 657 * Activates the item determined by @path. 658 * 659 * Params: 660 * path = The `GtkTreePath` to be activated 661 */ 662 public void itemActivated(TreePath path) 663 { 664 gtk_icon_view_item_activated(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 665 } 666 667 /** 668 * Returns %TRUE if the icon pointed to by @path is currently 669 * selected. If @path does not point to a valid location, %FALSE is returned. 670 * 671 * Params: 672 * path = A `GtkTreePath` to check selection on. 673 * 674 * Returns: %TRUE if @path is selected. 675 */ 676 public bool pathIsSelected(TreePath path) 677 { 678 return gtk_icon_view_path_is_selected(gtkIconView, (path is null) ? null : path.getTreePathStruct()) != 0; 679 } 680 681 /** 682 * Moves the alignments of @icon_view to the position specified by @path. 683 * @row_align determines where the row is placed, and @col_align determines 684 * where @column is placed. Both are expected to be between 0.0 and 1.0. 685 * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means 686 * center. 687 * 688 * If @use_align is %FALSE, then the alignment arguments are ignored, and the 689 * tree does the minimum amount of work to scroll the item onto the screen. 690 * This means that the item will be scrolled to the edge closest to its current 691 * position. If the item is currently visible on the screen, nothing is done. 692 * 693 * This function only works if the model is set, and @path is a valid row on 694 * the model. If the model changes before the @icon_view is realized, the 695 * centered path will be modified to reflect this change. 696 * 697 * Params: 698 * path = The path of the item to move to. 699 * useAlign = whether to use alignment arguments, or %FALSE. 700 * rowAlign = The vertical alignment of the item specified by @path. 701 * colAlign = The horizontal alignment of the item specified by @path. 702 */ 703 public void scrollToPath(TreePath path, bool useAlign, float rowAlign, float colAlign) 704 { 705 gtk_icon_view_scroll_to_path(gtkIconView, (path is null) ? null : path.getTreePathStruct(), useAlign, rowAlign, colAlign); 706 } 707 708 /** 709 * Selects all the icons. @icon_view must has its selection mode set 710 * to %GTK_SELECTION_MULTIPLE. 711 */ 712 public void selectAll() 713 { 714 gtk_icon_view_select_all(gtkIconView); 715 } 716 717 /** 718 * Selects the row at @path. 719 * 720 * Params: 721 * path = The `GtkTreePath` to be selected. 722 */ 723 public void selectPath(TreePath path) 724 { 725 gtk_icon_view_select_path(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 726 } 727 728 /** 729 * Calls a function for each selected icon. Note that the model or 730 * selection cannot be modified from within this function. 731 * 732 * Params: 733 * func = The function to call for each selected icon. 734 * data = User data to pass to the function. 735 */ 736 public void selectedForeach(GtkIconViewForeachFunc func, void* data) 737 { 738 gtk_icon_view_selected_foreach(gtkIconView, func, data); 739 } 740 741 /** 742 * Causes the `GtkIconView`::item-activated signal to be emitted on 743 * a single click instead of a double click. 744 * 745 * Params: 746 * single = %TRUE to emit item-activated on a single click 747 */ 748 public void setActivateOnSingleClick(bool single) 749 { 750 gtk_icon_view_set_activate_on_single_click(gtkIconView, single); 751 } 752 753 /** 754 * Sets the ::column-spacing property which specifies the space 755 * which is inserted between the columns of the icon view. 756 * 757 * Params: 758 * columnSpacing = the column spacing 759 */ 760 public void setColumnSpacing(int columnSpacing) 761 { 762 gtk_icon_view_set_column_spacing(gtkIconView, columnSpacing); 763 } 764 765 /** 766 * Sets the ::columns property which determines in how 767 * many columns the icons are arranged. If @columns is 768 * -1, the number of columns will be chosen automatically 769 * to fill the available area. 770 * 771 * Params: 772 * columns = the number of columns 773 */ 774 public void setColumns(int columns) 775 { 776 gtk_icon_view_set_columns(gtkIconView, columns); 777 } 778 779 /** 780 * Sets the current keyboard focus to be at @path, and selects it. This is 781 * useful when you want to focus the user’s attention on a particular item. 782 * If @cell is not %NULL, then focus is given to the cell specified by 783 * it. Additionally, if @start_editing is %TRUE, then editing should be 784 * started in the specified cell. 785 * 786 * This function is often followed by `gtk_widget_grab_focus 787 * (icon_view)` in order to give keyboard focus to the widget. 788 * Please note that editing can only happen when the widget is realized. 789 * 790 * Params: 791 * path = A `GtkTreePath` 792 * cell = One of the cell renderers of @icon_view 793 * startEditing = %TRUE if the specified cell should start being edited. 794 */ 795 public void setCursor(TreePath path, CellRenderer cell, bool startEditing) 796 { 797 gtk_icon_view_set_cursor(gtkIconView, (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct(), startEditing); 798 } 799 800 /** 801 * Sets the item that is highlighted for feedback. 802 * 803 * Params: 804 * path = The path of the item to highlight 805 * pos = Specifies where to drop, relative to the item 806 */ 807 public void setDragDestItem(TreePath path, GtkIconViewDropPosition pos) 808 { 809 gtk_icon_view_set_drag_dest_item(gtkIconView, (path is null) ? null : path.getTreePathStruct(), pos); 810 } 811 812 /** 813 * Sets the ::item-orientation property which determines whether the labels 814 * are drawn beside the icons instead of below. 815 * 816 * Params: 817 * orientation = the relative position of texts and icons 818 */ 819 public void setItemOrientation(GtkOrientation orientation) 820 { 821 gtk_icon_view_set_item_orientation(gtkIconView, orientation); 822 } 823 824 /** 825 * Sets the `GtkIconView`:item-padding property which specifies the padding 826 * around each of the icon view’s items. 827 * 828 * Params: 829 * itemPadding = the item padding 830 */ 831 public void setItemPadding(int itemPadding) 832 { 833 gtk_icon_view_set_item_padding(gtkIconView, itemPadding); 834 } 835 836 /** 837 * Sets the ::item-width property which specifies the width 838 * to use for each item. If it is set to -1, the icon view will 839 * automatically determine a suitable item size. 840 * 841 * Params: 842 * itemWidth = the width for each item 843 */ 844 public void setItemWidth(int itemWidth) 845 { 846 gtk_icon_view_set_item_width(gtkIconView, itemWidth); 847 } 848 849 /** 850 * Sets the ::margin property which specifies the space 851 * which is inserted at the top, bottom, left and right 852 * of the icon view. 853 * 854 * Params: 855 * margin = the margin 856 */ 857 public void setMargin(int margin) 858 { 859 gtk_icon_view_set_margin(gtkIconView, margin); 860 } 861 862 /** 863 * Sets the column with markup information for @icon_view to be 864 * @column. The markup column must be of type `G_TYPE_STRING`. 865 * If the markup column is set to something, it overrides 866 * the text column set by gtk_icon_view_set_text_column(). 867 * 868 * Params: 869 * column = A column in the currently used model, or -1 to display no text 870 */ 871 public void setMarkupColumn(int column) 872 { 873 gtk_icon_view_set_markup_column(gtkIconView, column); 874 } 875 876 /** 877 * Sets the model for a `GtkIconView`. 878 * If the @icon_view already has a model set, it will remove 879 * it before setting the new model. If @model is %NULL, then 880 * it will unset the old model. 881 * 882 * Params: 883 * model = The model. 884 */ 885 public void setModel(TreeModelIF model) 886 { 887 gtk_icon_view_set_model(gtkIconView, (model is null) ? null : model.getTreeModelStruct()); 888 } 889 890 /** 891 * Sets the column with pixbufs for @icon_view to be @column. The pixbuf 892 * column must be of type `GDK_TYPE_PIXBUF` 893 * 894 * Params: 895 * column = A column in the currently used model, or -1 to disable 896 */ 897 public void setPixbufColumn(int column) 898 { 899 gtk_icon_view_set_pixbuf_column(gtkIconView, column); 900 } 901 902 /** 903 * This function is a convenience function to allow you to reorder models that 904 * support the `GtkTreeDragSourceIface` and the `GtkTreeDragDestIface`. Both 905 * `GtkTreeStore` and `GtkListStore` support these. If @reorderable is %TRUE, then 906 * the user can reorder the model by dragging and dropping rows. The 907 * developer can listen to these changes by connecting to the model's 908 * row_inserted and row_deleted signals. The reordering is implemented by setting up 909 * the icon view as a drag source and destination. Therefore, drag and 910 * drop can not be used in a reorderable view for any other purpose. 911 * 912 * This function does not give you any degree of control over the order -- any 913 * reordering is allowed. If more control is needed, you should probably 914 * handle drag and drop manually. 915 * 916 * Params: 917 * reorderable = %TRUE, if the list of items can be reordered. 918 */ 919 public void setReorderable(bool reorderable) 920 { 921 gtk_icon_view_set_reorderable(gtkIconView, reorderable); 922 } 923 924 /** 925 * Sets the ::row-spacing property which specifies the space 926 * which is inserted between the rows of the icon view. 927 * 928 * Params: 929 * rowSpacing = the row spacing 930 */ 931 public void setRowSpacing(int rowSpacing) 932 { 933 gtk_icon_view_set_row_spacing(gtkIconView, rowSpacing); 934 } 935 936 /** 937 * Sets the selection mode of the @icon_view. 938 * 939 * Params: 940 * mode = The selection mode 941 */ 942 public void setSelectionMode(GtkSelectionMode mode) 943 { 944 gtk_icon_view_set_selection_mode(gtkIconView, mode); 945 } 946 947 /** 948 * Sets the ::spacing property which specifies the space 949 * which is inserted between the cells (i.e. the icon and 950 * the text) of an item. 951 * 952 * Params: 953 * spacing = the spacing 954 */ 955 public void setSpacing(int spacing) 956 { 957 gtk_icon_view_set_spacing(gtkIconView, spacing); 958 } 959 960 /** 961 * Sets the column with text for @icon_view to be @column. The text 962 * column must be of type `G_TYPE_STRING`. 963 * 964 * Params: 965 * column = A column in the currently used model, or -1 to display no text 966 */ 967 public void setTextColumn(int column) 968 { 969 gtk_icon_view_set_text_column(gtkIconView, column); 970 } 971 972 /** 973 * Sets the tip area of @tooltip to the area which @cell occupies in 974 * the item pointed to by @path. See also gtk_tooltip_set_tip_area(). 975 * 976 * See also gtk_icon_view_set_tooltip_column() for a simpler alternative. 977 * 978 * Params: 979 * tooltip = a `GtkTooltip` 980 * path = a `GtkTreePath` 981 * cell = a `GtkCellRenderer` 982 */ 983 public void setTooltipCell(Tooltip tooltip, TreePath path, CellRenderer cell) 984 { 985 gtk_icon_view_set_tooltip_cell(gtkIconView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct()); 986 } 987 988 /** 989 * If you only plan to have simple (text-only) tooltips on full items, you 990 * can use this function to have `GtkIconView` handle these automatically 991 * for you. @column should be set to the column in @icon_view’s model 992 * containing the tooltip texts, or -1 to disable this feature. 993 * 994 * When enabled, `GtkWidget:has-tooltip` will be set to %TRUE and 995 * @icon_view will connect a `GtkWidget::query-tooltip` signal handler. 996 * 997 * Note that the signal handler sets the text with gtk_tooltip_set_markup(), 998 * so &, <, etc have to be escaped in the text. 999 * 1000 * Params: 1001 * column = an integer, which is a valid column number for @icon_view’s model 1002 */ 1003 public void setTooltipColumn(int column) 1004 { 1005 gtk_icon_view_set_tooltip_column(gtkIconView, column); 1006 } 1007 1008 /** 1009 * Sets the tip area of @tooltip to be the area covered by the item at @path. 1010 * See also gtk_icon_view_set_tooltip_column() for a simpler alternative. 1011 * See also gtk_tooltip_set_tip_area(). 1012 * 1013 * Params: 1014 * tooltip = a `GtkTooltip` 1015 * path = a `GtkTreePath` 1016 */ 1017 public void setTooltipItem(Tooltip tooltip, TreePath path) 1018 { 1019 gtk_icon_view_set_tooltip_item(gtkIconView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct()); 1020 } 1021 1022 /** 1023 * Unselects all the icons. 1024 */ 1025 public void unselectAll() 1026 { 1027 gtk_icon_view_unselect_all(gtkIconView); 1028 } 1029 1030 /** 1031 * Unselects the row at @path. 1032 * 1033 * Params: 1034 * path = The `GtkTreePath` to be unselected. 1035 */ 1036 public void unselectPath(TreePath path) 1037 { 1038 gtk_icon_view_unselect_path(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 1039 } 1040 1041 /** 1042 * Undoes the effect of gtk_icon_view_enable_model_drag_dest(). Calling this 1043 * method sets `GtkIconView`:reorderable to %FALSE. 1044 */ 1045 public void unsetModelDragDest() 1046 { 1047 gtk_icon_view_unset_model_drag_dest(gtkIconView); 1048 } 1049 1050 /** 1051 * Undoes the effect of gtk_icon_view_enable_model_drag_source(). Calling this 1052 * method sets `GtkIconView`:reorderable to %FALSE. 1053 */ 1054 public void unsetModelDragSource() 1055 { 1056 gtk_icon_view_unset_model_drag_source(gtkIconView); 1057 } 1058 1059 /** 1060 * A [keybinding signal][class@Gtk.SignalAction] 1061 * which gets emitted when the user activates the currently 1062 * focused item. 1063 * 1064 * Applications should not connect to it, but may emit it with 1065 * g_signal_emit_by_name() if they need to control activation 1066 * programmatically. 1067 * 1068 * The default bindings for this signal are Space, Return and Enter. 1069 */ 1070 gulong addOnActivateCursorItem(bool delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1071 { 1072 return Signals.connect(this, "activate-cursor-item", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1073 } 1074 1075 /** 1076 * The ::item-activated signal is emitted when the method 1077 * gtk_icon_view_item_activated() is called, when the user double 1078 * clicks an item with the "activate-on-single-click" property set 1079 * to %FALSE, or when the user single clicks an item when the 1080 * "activate-on-single-click" property set to %TRUE. It is also 1081 * emitted when a non-editable item is selected and one of the keys: 1082 * Space, Return or Enter is pressed. 1083 * 1084 * Params: 1085 * path = the `GtkTreePath` for the activated item 1086 */ 1087 gulong addOnItemActivated(void delegate(TreePath, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1088 { 1089 return Signals.connect(this, "item-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1090 } 1091 1092 /** 1093 * The ::move-cursor signal is a 1094 * [keybinding signal][class@Gtk.SignalAction] 1095 * which gets emitted when the user initiates a cursor movement. 1096 * 1097 * Applications should not connect to it, but may emit it with 1098 * g_signal_emit_by_name() if they need to control the cursor 1099 * programmatically. 1100 * 1101 * The default bindings for this signal include 1102 * - Arrow keys which move by individual steps 1103 * - Home/End keys which move to the first/last item 1104 * - PageUp/PageDown which move by "pages" 1105 * All of these will extend the selection when combined with 1106 * the Shift modifier. 1107 * 1108 * Params: 1109 * step = the granularity of the move, as a `GtkMovementStep` 1110 * count = the number of @step units to move 1111 * extend = whether to extend the selection 1112 * modify = whether to modify the selection 1113 */ 1114 gulong addOnMoveCursor(bool delegate(GtkMovementStep, int, bool, bool, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1115 { 1116 return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1117 } 1118 1119 /** 1120 * A [keybinding signal][class@Gtk.SignalAction] 1121 * which gets emitted when the user selects all items. 1122 * 1123 * Applications should not connect to it, but may emit it with 1124 * g_signal_emit_by_name() if they need to control selection 1125 * programmatically. 1126 * 1127 * The default binding for this signal is Ctrl-a. 1128 */ 1129 gulong addOnSelectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1130 { 1131 return Signals.connect(this, "select-all", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1132 } 1133 1134 /** 1135 * A [keybinding signal][class@Gtk.SignalAction] 1136 * which gets emitted when the user selects the item that is currently 1137 * focused. 1138 * 1139 * Applications should not connect to it, but may emit it with 1140 * g_signal_emit_by_name() if they need to control selection 1141 * programmatically. 1142 * 1143 * There is no default binding for this signal. 1144 */ 1145 gulong addOnSelectCursorItem(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1146 { 1147 return Signals.connect(this, "select-cursor-item", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1148 } 1149 1150 /** 1151 * The ::selection-changed signal is emitted when the selection 1152 * (i.e. the set of selected items) changes. 1153 */ 1154 gulong addOnSelectionChanged(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1155 { 1156 return Signals.connect(this, "selection-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1157 } 1158 1159 /** 1160 * A [keybinding signal][class@Gtk.SignalAction] 1161 * which gets emitted when the user toggles whether the currently 1162 * focused item is selected or not. The exact effect of this 1163 * depend on the selection mode. 1164 * 1165 * Applications should not connect to it, but may emit it with 1166 * g_signal_emit_by_name() if they need to control selection 1167 * programmatically. 1168 * 1169 * There is no default binding for this signal is Ctrl-Space. 1170 */ 1171 gulong addOnToggleCursorItem(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1172 { 1173 return Signals.connect(this, "toggle-cursor-item", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1174 } 1175 1176 /** 1177 * A [keybinding signal][class@Gtk.SignalAction] 1178 * which gets emitted when the user unselects all items. 1179 * 1180 * Applications should not connect to it, but may emit it with 1181 * g_signal_emit_by_name() if they need to control selection 1182 * programmatically. 1183 * 1184 * The default binding for this signal is Ctrl-Shift-a. 1185 */ 1186 gulong addOnUnselectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1187 { 1188 return Signals.connect(this, "unselect-all", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1189 } 1190 }